#pragma once

#include <cstdlib>
#include <ctime>

inline int InitRandomSystem()
{
	static bool inited = false;
	static int seed = static_cast<unsigned int>(time(0));
	if(!inited)
	{
		inited = true;
		srand(seed);
		seed = rand();
		srand(seed);
	}
	return seed;
}

inline int MultiRand(const size_t i_range, const size_t i_numRands)
{
	int sum=0;
	for(size_t i=0; i<i_numRands; ++i)
		sum += rand()%i_range;
	return sum;
}

inline float RandFloat()
{
	return static_cast<float>(rand()%(RAND_MAX) ) / static_cast<float>(RAND_MAX-1);
}

inline float RandFloatBetween(float i_min, float i_max)
{
	float delta = i_max - i_min;
	float r = RandFloat();
	return i_min + r * delta;
}

inline int RandIntBetween(int i_min, int i_max)
{
	const int delta = i_max - i_min;
	return i_min + rand()%(1+delta);
}